Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 6x 6x 6x 5x 5x 5x 2x 2x 1x | import { NextRequest, NextResponse } from "next/server";
import { requireAuth } from "@/lib/auth";
import { CollectionController } from "@/server/api/collections";
import { requireApiCapability } from "@/server/dal/collection-access";
import { getDb } from "@/lib/db";
import { errorResponse } from "@/server/api/http-errors";
export async function POST(
_request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const user = await requireAuth();
const db = getDb();
// requireApiCapability resolves-then-authorizes: 404 absent, 403 not owner.
const access = await requireApiCapability(db, id, user.id, "collection:manage");
if (access instanceof NextResponse) return access;
const collection = await CollectionController.fromDb(db).archiveCollection(id);
return NextResponse.json(collection);
} catch (error) {
return errorResponse(error);
}
}
|